function [output] = squaregen(A, w, A0, x)
temp = 0;
n = prod(size(x));
flag = 0;
dt = max(max(x))/n;
for i = 1 : n
    if flag == 0
        output(i) = -A + A0;
    else
        output(i) = A + A0;
    end
    temp = temp + dt;
    if temp > 1/w 
        temp = 0;
        flag = 1 - flag;
    end
end